package com.sunwayhorizo.health.hl7.persistent;

import com.sunwayhorizo.health.hl7.factories.ReferenceModifier;
import com.sunwayhorizo.health.hl7.persistent.pk.RimCoreEntitiesPK;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Id;
import javax.persistence.IdClass;

@Entity
@AttributeOverrides({
/*
 * @AttributeOverride(name = "systemId", column = @Column(name = "ENTITY_ID")),
 * 
 * @AttributeOverride(name = "versionNum", column = @Column(name =
 * "ENTITY_VERSION_NUM")),
 */
@AttributeOverride(name = "codeEtsId", column = @Column(name = "ENTITY_CODE_ETS_ID")) })
@TableGenerator(name = "Entity_IdGenerator", table = "RIM_Id_Generator", pkColumnName = "pkColumn", valueColumnName = "valueColumn", pkColumnValue = "Entity_Id")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "PARTITION_BY_CLASS", discriminatorType = DiscriminatorType.STRING)
@DiscriminatorValue("RimCoreEntities")
@Table(name = "RIM_CORE_ENTITIES")
@IdClass(RimCoreEntitiesPK.class)
public class RimCoreEntities extends InfrastructureRoot
{

    // ϵͳ���Ĺ���
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "Entity_IdGenerator")
    @Column(name = "ENTITY_ID", nullable = false)
    private Long entityId;
    @Id
    @Column(name = "ENTITY_VERSION_NUM", nullable = false)
    private Long entityVersionNum;

    // Entity ά��Roles,player and scoper
    @OneToMany(mappedBy = "playerEntities", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<RimCoreRoles> playerRolesList = new ArrayList<RimCoreRoles>();

    @OneToMany(mappedBy = "scoperEntities", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<RimCoreRoles> scoperRolesList = new ArrayList<RimCoreRoles>();

    @OneToMany(mappedBy = "rimCoreEntities", fetch = FetchType.LAZY, targetEntity = RimCoreEntyIi.class, cascade = CascadeType.ALL)
    private List<RimCoreEntyIi> entyIiList = new ArrayList<RimCoreEntyIi>();

    @OneToMany(mappedBy = "rimCoreEntities", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<RimCoreEntyCdSets> entyCdSetsList = new ArrayList<RimCoreEntyCdSets>();

    @OneToMany(mappedBy = "rimCoreEntities", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<RimCoreEntyNames> entyNamesList = new ArrayList<RimCoreEntyNames>();

    @OneToMany(mappedBy = "rimCoreEntities", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<RimCoreEntyAddrs> entyAddrsList = new ArrayList<RimCoreEntyAddrs>();

    @OneToMany(mappedBy = "rimCoreEntities", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<RimCoreEntyTelAddrs> entyTelAddrsList = new ArrayList<RimCoreEntyTelAddrs>();

    @OneToMany(mappedBy = "rimCoreEntities", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<RimCoreEntyQtys> entyQtysList = new ArrayList<RimCoreEntyQtys>();

    @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name = "DESC_ED_ID", referencedColumnName = "ED_ID")
    private RimCoreEds rimCoreEdsDescEdId = new RimCoreEds();

    @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name = "NP_STRAIN_TEXT_ED_ID", referencedColumnName = "ED_ID", insertable = false, updatable = false)
    private RimCoreEds rimCoreEdsNpStrainTextId = new RimCoreEds();

    @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name = "PL_DIRECTIONS_TEXT_ED_ID", referencedColumnName = "ED_ID")
    private RimCoreEds rimCoreEdsPlDirectionsTextId = new RimCoreEds();

    @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name = "PL_POSITION_TEXT_ED_ID", referencedColumnName = "ED_ID")
    private RimCoreEds rimCoreEdsPlPositionTextId = new RimCoreEds();


    public RimCoreEntities()
    {
        Long i = new Long(1);
        entityVersionNum = i;
    }


    public RimCoreEntities(ReferenceModifier referencemodifier)
    {
        super(referencemodifier);
        Long i = new Long(1);
        entityVersionNum = i;
    }


    // EntyIi
    private void setEntyIiList(List<RimCoreEntyIi> rimCoreEntyIiList)
    {
        this.entyIiList = rimCoreEntyIiList;
    }


    public List<RimCoreEntyIi> getEntyIiList()
    {
        return entyIiList;
    }


    protected RimCoreEntyIi addEntyIi(RimCoreEntyIi entyIi)
    {
        getEntyIiList().add(entyIi);
        entyIi.setRimCoreEntities(this);
        return entyIi;
    }


    public void removeEntyIi(RimCoreEntyIi entyIi)
    {
        getEntyIiList().remove(entyIi);
        entyIi.setRimCoreEntities(null);
        // return entyIi;
    }


    // EntyCdSets
    /**
     * RimCoreEntities控制RimCoreEntyCdSets
     */
    private void setEntyCdSetsList(List<RimCoreEntyCdSets> entyCdSetsList)
    {
        this.entyCdSetsList = entyCdSetsList;
    }


    public List<RimCoreEntyCdSets> getEntyCdSetsList()
    {
        return entyCdSetsList;
    }


    protected RimCoreEntyCdSets addEntyCdSets(RimCoreEntyCdSets entyCdSets)
    {
        getEntyCdSetsList().add(entyCdSets);
        entyCdSets.setRimCoreEntities(this);
        return entyCdSets;
    }


    protected RimCoreEntyCdSets removeEntyCdSets(RimCoreEntyCdSets entyCdSets)
    {
        getEntyCdSetsList().add(entyCdSets);
        entyCdSets.setRimCoreEntities(null);
        return entyCdSets;
    }


    // EntyNames
    private void setEntyNamesList(List<RimCoreEntyNames> rimCoreEntyNamesList)
    {
        this.entyNamesList = rimCoreEntyNamesList;
    }


    public List<RimCoreEntyNames> getEntyNamesList()
    {
        return entyNamesList;
    }


    protected RimCoreEntyNames addEntyNames(RimCoreEntyNames entyNames)
    {
        getEntyNamesList().add(entyNames);
        entyNames.setRimCoreEntities(this);
        return entyNames;
    }


    public RimCoreEntyNames removeEntyNames(RimCoreEntyNames entyNames)
    {
        getEntyNamesList().remove(entyNames);
        entyNames.setRimCoreEntities(null);
        return entyNames;
    }


    // EntyAddrs
    public void setEntyAddrsList(List<RimCoreEntyAddrs> rimCoreEntyAddrsList)
    {
        this.entyAddrsList = rimCoreEntyAddrsList;
    }


    public List<RimCoreEntyAddrs> getEntyAddrsList()
    {
        return entyAddrsList;
    }


    protected RimCoreEntyAddrs addEntyAddrs(RimCoreEntyAddrs entyAddrs)
    {
        getEntyAddrsList().add(entyAddrs);
        entyAddrs.setRimCoreEntities(this);
        return entyAddrs;
    }


    protected RimCoreEntyAddrs removeEntyAddrs(RimCoreEntyAddrs entyAddrs)
    {
        getEntyAddrsList().remove(entyAddrs);
        entyAddrs.setRimCoreEntities(null);
        return entyAddrs;
    }


    // EntyTelAddrs
    private void setEntyTelAddrsList(List<RimCoreEntyTelAddrs> rimCoreEntyTelAddrsList)
    {
        this.entyTelAddrsList = rimCoreEntyTelAddrsList;
    }


    public List<RimCoreEntyTelAddrs> getEntyTelAddrsList()
    {
        return entyTelAddrsList;
    }


    protected RimCoreEntyTelAddrs addEntyTelAddrs(RimCoreEntyTelAddrs entyTelAddrs)
    {
        getEntyTelAddrsList().add(entyTelAddrs);
        entyTelAddrs.setRimCoreEntities(this);
        return entyTelAddrs;
    }


    protected RimCoreEntyTelAddrs removeEntyTelAddrs(RimCoreEntyTelAddrs entyTelAddrs)
    {
        getEntyTelAddrsList().remove(entyTelAddrs);
        entyTelAddrs.setRimCoreEntities(null);
        return entyTelAddrs;
    }


    // EntyQtys
    private void setEntyQtysList(List<RimCoreEntyQtys> entyQtysList)
    {
        this.entyQtysList = entyQtysList;
    }


    public List<RimCoreEntyQtys> getEntyQtysList()
    {
        return entyQtysList;
    }


    protected RimCoreEntyQtys addEntyQtys(RimCoreEntyQtys entyQtys)
    {
        getEntyQtysList().add(entyQtys);
        entyQtys.setRimCoreEntities(this);
        return entyQtys;
    }


    protected RimCoreEntyQtys removeEntyQtys(RimCoreEntyQtys entyQtys)
    {
        getEntyQtysList().remove(entyQtys);
        entyQtys.setRimCoreEntities(null);
        return entyQtys;
    }


    // AddPlayerRoles
    private void setPlayerRimCoreRolesList(List<RimCoreRoles> playerRimCoreRolesList)
    {
        this.playerRolesList = playerRimCoreRolesList;
    }


    public List<RimCoreRoles> getPlayerRimCoreRolesList()
    {
        return playerRolesList;
    }


    public RimCoreRoles addPlayerRoles(RimCoreRoles playerRoles)
    {
        getPlayerRimCoreRolesList().add(playerRoles);
        playerRoles.setPlayerEntities(this);
        return playerRoles;
    }


    public RimCoreRoles removePlayerRoles(RimCoreRoles playerRoles)
    {
        getPlayerRimCoreRolesList().remove(playerRoles);
        playerRoles.setPlayerEntities(null);
        return playerRoles;
    }


    // AddScoperRoles
    private void setScoperRimCoreRolesList(List<RimCoreRoles> scoperRimCoreRolesList)
    {
        this.scoperRolesList = scoperRimCoreRolesList;
    }


    public List<RimCoreRoles> getScoperRimCoreRolesList()
    {
        return scoperRolesList;
    }


    public RimCoreRoles addScoperRoles(RimCoreRoles scoperRoles)
    {
        getScoperRimCoreRolesList().add(scoperRoles);
        scoperRoles.setScoperEntities(this);
        return scoperRoles;
    }


    public RimCoreRoles removeScoperRoles(RimCoreRoles scoperRoles)
    {
        this.getScoperRimCoreRolesList().remove(scoperRoles);
        scoperRoles.setScoperEntities(null);
        return scoperRoles;
    }


    protected void setRimCoreEdsDescEdId(RimCoreEds rimCoreEdsDescEdId)
    {
        this.rimCoreEdsDescEdId = rimCoreEdsDescEdId;
    }


    protected RimCoreEds getRimCoreEdsDescEdId()
    {
        return rimCoreEdsDescEdId;
    }


    protected void setRimCoreEdsNpStrainTextId(RimCoreEds rimCoreEdsNpStrainTextId)
    {
        this.rimCoreEdsNpStrainTextId = rimCoreEdsNpStrainTextId;
    }


    protected RimCoreEds getRimCoreEdsNpStrainTextId()
    {
        return rimCoreEdsNpStrainTextId;
    }


    protected void setRimCoreEdsPlDirectionsTextId(RimCoreEds rimCoreEdsPlDirectionsTextId)
    {
        this.rimCoreEdsPlDirectionsTextId = rimCoreEdsPlDirectionsTextId;
    }


    protected RimCoreEds getRimCoreEdsPlDirectionsTextId()
    {
        return rimCoreEdsPlDirectionsTextId;
    }


    protected void setRimCoreEdsPlPositionTextId(RimCoreEds rimCoreEdsPlPositionTextId)
    {
        this.rimCoreEdsPlPositionTextId = rimCoreEdsPlPositionTextId;
    }


    protected RimCoreEds getRimCoreEdsPlPositionTextId()
    {
        return rimCoreEdsPlPositionTextId;
    }


    public void setEntityId(Long entityId)
    {
        this.entityId = entityId;
    }


    public Long getEntityId()
    {
        return entityId;
    }


    public void setEntityVersionNum(Long entityVersionNum)
    {
        this.entityVersionNum = entityVersionNum;
    }


    public Long getEntityVersionNum()
    {
        return entityVersionNum;
    }

}
